﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WordWonderGame.UI.Man2;
using WordWonderGame.Business;
using System.Media;

namespace WordWonderGame.UI
{
    public partial class FormMan2 : UserControl
    {
       // int soTuHienTai = -1;
        private TraLoiUI traloiUI;
        private KetQuaUI ketquaUI;
        public event EventHandler QuaMan2Roi;
        public FormMan2()
        {
            InitializeComponent();
            //traloiUI
            traloiUI = new TraLoiUI();
            traloiUI.Dock = DockStyle.Fill;
            traloiUI.Parent = pnTraLoi;
            traloiUI.Visible = false;
            traloiUI.TraLoiDung += new EventHandler(traloiUI_TraLoiDung);
            traloiUI.TraLoiSai += new EventHandler(traloiUI_TraLoiSai);
            traloiUI.XongMan2 += new EventHandler(traloiUI_XongMan2);
            
            //ketquaUI
            ketquaUI = new KetQuaUI();
            ketquaUI.HienDapAn += new EventHandler(ketquaUI_HienDapAn);
            ketquaUI.Dock = DockStyle.Fill;
            ketquaUI.Parent = pnKetQua;
            ketquaUI.Visible = false;
            ketquaUI.QuaMan2Roi += new EventHandler(ketquaUI_QuaMan2Roi);
            //
          
        }

        void ketquaUI_HienDapAn(object sender, EventArgs e)
        {
            traloiUI.Hetgio();
        }

        void ketquaUI_QuaMan2Roi(object sender, EventArgs e)
        {
            if (QuaMan2Roi != null)
            {
                QuaMan2Roi(sender, null);
            }
        }

        void traloiUI_XongMan2(object sender, EventArgs e)
        {
            ketquaUI.CongDiemXongGame();
        }

        void traloiUI_TraLoiDung(object sender, EventArgs e)
        {
            ketquaUI.CongDiem();
            ketquaUI.TraLoiDung();
        }
        void traloiUI_TraLoiSai(object sender, EventArgs e)
        {
            ketquaUI.TraLoiSai();
        }


        private void btBatDau_Click(object sender, EventArgs e)
        {
            SoundPlayer playerbutton = new SoundPlayer(@"Sound\button_click.wav");
            playerbutton.Play();
            btBatDau.Visible = false;
            traloiUI.Visible = true;
            
            DataClassDAL dataClass = new DataClassDAL();
            CauHoiMan2 c = dataClass.LayCauHoiMan2();
            traloiUI.LoadTuTraLoi(c.ListDapAn, c.ListGoiY);
            ///////////////////////
            ketquaUI.Visible = true;
            ketquaUI.StartThoiGian();
           
        }

        private void FormMan2_Load(object sender, EventArgs e)
        {

        }

    }
}
